/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = wtc_tcb_tran.c                                     */
/*  NOTE      =                                                    */
/*  DATE      = 2015/08/26 by songbb                               */
/*******************************************************************/

#include "conntrack.h"

#include "../wtc_core.h"
#include "../wtc_mar.h"
#include "wtc_tcb_tran.h"

int wtc_tcb_tran_tmpostrecv(Conntrack *p_st_conn
                            , Apm_packet *p_analyze_in
                            , L7session_wtc *p_st_sess
                            , L7_wtc_packet *p_st_wtc_packet
                            , int i_recv_size
                            , int i_hint_index)
{
    unsigned int ui_tmp = 0;
    int i_is_commit_logged;

    i_recv_size -= 32;
    if (bytebuff_skip(p_st_wtc_packet->p_st_packet, 24) != FR_SUCC)
        goto error;
    if (bytebuff_get_int(p_st_wtc_packet->p_st_packet, 4, &ui_tmp, BYTE_BIG_ENDIAN) != FR_SUCC)
        goto error;
    i_is_commit_logged = (ui_tmp & 0x200) != 0 ? FR_YES : FR_NO;
    if (bytebuff_skip(p_st_wtc_packet->p_st_packet, 4) != FR_SUCC)
        goto error;
    if (bytebuff_skip(p_st_wtc_packet->p_st_packet, (size_t) i_recv_size) != FR_SUCC)
        goto error;

    return FR_SUCC;
error:
    return FR_FAIL;
}

int wtc_tcb_tran_tmpostrecv_fad(char *p_payload
                                , unsigned int ui_payload_len
                                , unsigned int *p_ui_offset
                                , int *p_i_direction
                                , int i_recv_size
                                , int i_hint_index)
{
    i_recv_size -= 32;
    if (wtc_skip(p_payload, ui_payload_len, p_ui_offset, 32) != FR_SUCC)
        goto error;
    if (wtc_skip(p_payload, ui_payload_len, p_ui_offset, i_recv_size) != FR_SUCC)
        goto error;
    return FR_SUCC;
error:
    return FR_FAIL;
}
